home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / nhost.arc / HCONFIG.SLT < prev    next >
Text File  |  1989-10-08  |  5KB  |  247 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   H C O N F I G . S L T
  4. //
  5. //   Copyright (C) 1988 PTel and Colin Sampaleanu
  6. //
  7. //   This is a Host Mode configuration script for Telix.
  8. //   It reads form and saves parameters to the file HOST.CNF,
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. str pass1[8] = "pass1",
  13.     pass2[8] = "pass2",
  14.     shellpass[8] = "shell",
  15.     shutpass[8] = "shut",
  16.     host_downloads[64],
  17.     host_uploads[64];    
  18. int direct_connect = 0;
  19.  
  20. //////////////////////////////////////////////////////////////////////////////
  21.  
  22. main()
  23.  
  24. {
  25.  
  26.  read_host_config_file();
  27.  host_configure();
  28.  
  29. }
  30.  
  31. //////////////////////////////////////////////////////////////////////////////
  32.  
  33. read_host_config_file()
  34.  
  35. {
  36.  str s[80];
  37.  int f, stat;
  38.  
  39.  s = _telix_dir;
  40.  strcat(s, "HOST.CNF");
  41.  
  42.  f = fopen(s, "r");
  43.  if (!f)
  44.   {
  45.    printsc("Can't open ");
  46.    prints(s);
  47.    return -1;
  48.   }
  49.  
  50.  stat = fgets(s, 80, f);
  51.  if (stat == -1)
  52.   goto got_error;
  53.  pass1 = s;
  54.  
  55.  stat = fgets(s, 80, f);
  56.  if (stat == -1)
  57.   goto got_error;
  58.  pass2 = s;
  59.  
  60.  stat = fgets(s, 80, f);
  61.  if (stat == -1)
  62.   goto got_error;
  63.  shellpass = s;
  64.  
  65.  stat = fgets(s, 80, f);
  66.  if (stat == -1)
  67.   goto got_error;
  68.  shutpass = s;
  69.  
  70.  stat = fgets(s, 80, f);
  71.  if (stat == -1)
  72.   goto got_error;
  73.  host_downloads = s;
  74.  
  75.  stat = fgets(s, 80, f);
  76.  if (stat == -1)
  77.   goto got_error;
  78.  host_uploads = s;
  79.  
  80.  stat = fgets(s, 80, f);
  81.  if (stat == -1)
  82.   goto got_error;
  83.  direct_connect = (toupper(subchr(s, 0)) == 'D');
  84.  
  85.  fclose(f);
  86.  return 1;
  87.  
  88. // jump here if error
  89.  
  90.  got_error:
  91.   fclose(f);
  92.   return -1;
  93.  
  94. }
  95.  
  96. //////////////////////////////////////////////////////////////////////////////
  97.  
  98. host_configure()
  99.  
  100. {
  101.  str s[100];
  102.  int c, f, i, stat;
  103.  
  104.  if (!host_downloads)
  105.   {
  106.    host_downloads = _telix_dir;
  107.    strcat(host_downloads, "HSTFILES\");
  108.   }
  109.  
  110.  if (!host_uploads)
  111.   {
  112.    host_uploads = _telix_dir;
  113.    strcat(host_uploads, "HSTFILES\");
  114.   }
  115.  
  116.  while (1)
  117.   {
  118.    prints("^M^JHCONFIG - Host Mode Configuration Script^M^J");
  119.    printsc("A: Level 1 password       : ");
  120.    prints(pass1);
  121.    printsc("B: Level 2 password       : ");
  122.    prints(pass2);
  123.    printsc("C: Remote Shell password  : ");
  124.    prints(shellpass);
  125.    printsc("D: Shut down host pass    : ");
  126.    prints(shutpass);
  127.    printsc("E: Host download directory: ");
  128.    prints(host_downloads);
  129.    printsc("F: Host upload directory  : ");
  130.    prints(host_uploads);
  131.    printsc("G: Connection type        : ");
  132.    if (direct_connect)
  133.     prints("Direct");
  134.    else
  135.     prints("Modem");
  136.  
  137.    prints("^M^JH: Exit without saving changes.");
  138.    prints("I: Exit and save changes to disk.^M^J");
  139.  
  140.    printsc("Which option? ");
  141.    gets(s, 1);
  142.    prints("");
  143.    c = toupper(subchr(s, 0));
  144.    if (c < 'A' || c > 'I')
  145.     continue;
  146.  
  147.    if (c >= 'A' && c <= 'G')
  148.     printsc("Enter new value (Esc to abort): ");
  149.  
  150.    if (c == 'A')
  151.     {
  152.      stat = gets(s, 8);
  153.      if (stat != -1)
  154.       pass1 = s;
  155.     }
  156.    else if (c == 'B')
  157.     {
  158.      stat = gets(s, 8);
  159.      if (stat != -1)
  160.       pass2 = s;
  161.     }
  162.    else if (c == 'C')
  163.     {
  164.      stat = gets(s, 8);
  165.      if (stat != -1)
  166.       shellpass = s;
  167.     }
  168.    else if (c == 'D')
  169.     {
  170.      stat = gets(s, 8);
  171.      if (stat != -1)
  172.       shutpass = s;
  173.     }
  174.    else if (c == 'E')
  175.     {
  176.      stat = gets(s, 48);
  177.      if (stat != -1)
  178.       {
  179.        host_downloads = s;
  180.        strupper(host_downloads);
  181.       }
  182.      if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  183.       if (subchr(host_downloads, i - 1) != '\')
  184.        copystr("\", host_downloads, i, 1);
  185.     }
  186.    else if (c == 'F')
  187.     {
  188.      stat = gets(s, 48);
  189.      if (stat != -1)
  190.       {
  191.        host_uploads = s;
  192.        strupper(host_uploads);
  193.       }
  194.      if ((i = strlen(host_uploads)) != 0)
  195.       if (subchr(host_uploads, i - 1) != '\')
  196.        copystr("\", host_uploads, i, 1);
  197.     }
  198.    else if (c == 'G')
  199.     {
  200.      stat = gets(s, 7);
  201.      if (stat != -1)
  202.       direct_connect = (toupper(subchr(s, 0)) == 'D');
  203.     }
  204.  
  205.    else if (c == 'H')
  206.     {
  207.      prints("^M^JHCONFIG done.^M^J");
  208.      return;
  209.     }
  210.    else if (c == 'I')
  211.     {
  212.      s = _telix_dir;
  213.      strcat(s, "HOST.CNF");
  214.      f = fopen(s, "w");
  215.  
  216.      if (!f)
  217.       {
  218.        printsc("Error writing to ");
  219.        printsc(s);
  220.        prints("!");
  221.        continue;
  222.       }
  223.  
  224.      fputs(pass1, f);
  225.      fputs("^M^J", f);
  226.      fputs(pass2, f);
  227.      fputs("^M^J", f);
  228.      fputs(shellpass, f);
  229.      fputs("^M^J", f);
  230.      fputs(shutpass, f);
  231.      fputs("^M^J", f);
  232.      fputs(host_downloads, f);
  233.      fputs("^M^J", f);
  234.      fputs(host_uploads, f);
  235.      fputs("^M^J", f);
  236.      if (direct_connect)
  237.       fputs("Direct^M^J", f);
  238.      else
  239.       fputs("Modem^M^J", f);
  240.  
  241.      prints("^M^JHCONFIG done.^M^J");
  242.      fclose(f);
  243.      return;
  244.     }
  245.   }
  246. }
  247.